home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
cat3
/
CrtSelHdlr.3
< prev
next >
Wrap
Text File
|
1994-09-20
|
7KB
|
199 lines
Tk_CreateSelHandler(3)Tk Library Procedures
_________________________________________________________________
NAME
Tk_CreateSelHandler, Tk_DeleteSelHandler - arrange to handle
requests for the primary selection
SYNOPSIS
#include <tk.h>
Tk_CreateSelHandler(_t_k_w_i_n, _t_a_r_g_e_t, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a, _f_o_r_m_a_t)
Tk_DeleteSelHandler(_t_k_w_i_n, _t_a_r_g_e_t)
ARGUMENTS
Tk_Window _t_k_w_i_n (in) Window for which
_p_r_o_c will provide
selection informa-
tion.
Atom _t_a_r_g_e_t (in) Form in which _p_r_o_c
can provide the
selection (e.g.
STRING or
FILE_NAME).
Corresponds to
_t_y_p_e arguments in
selection com-
mands.
Tk_SelectionProc *_p_r_o_c (in) Procedure to
invoke whenever
the selection is
owned by _t_k_w_i_n and
the selection con-
tents are
requested in the
format given by
_t_a_r_g_e_t.
ClientData _c_l_i_e_n_t_D_a_t_a (in) Arbitrary one-word
value to pass to
_p_r_o_c.
Atom _f_o_r_m_a_t (in) If the selection
requestor isn't in
this process, _f_o_r_-
_m_a_t determines the
representation
used to transmit
the selection to
its requestor.
_________________________________________________________________
Tk 1
Tk_CreateSelHandler(3)Tk Library Procedures
DESCRIPTION
Tk_CreateSelHandler arranges for a particular procedure
(_p_r_o_c) to be called whenever the selection is owned by _t_k_w_i_n
and the selection contents are requested in the form given
by _t_a_r_g_e_t. _T_a_r_g_e_t should be one of the entries defined in
the left column of Table 2 of the X Inter-Client Communica-
tion Conventions Manual (ICCCM) or any other form in which
an application is willing to present the selection. The
most common form is STRING.
_P_r_o_c should have arguments and result that match the type
Tk_SelectionProc:
typedef int Tk_SelectionProc(
ClientData _c_l_i_e_n_t_D_a_t_a,
int _o_f_f_s_e_t,
char *_b_u_f_f_e_r,
int _m_a_x_B_y_t_e_s);
The _c_l_i_e_n_t_D_a_t_a parameter to _p_r_o_c is a copy of the _c_l_i_e_n_t_D_a_t_a
argument given to Tk_CreateSelHandler. Typically, _c_l_i_e_n_t_-
_D_a_t_a points to a data structure containing application-
specific information that is needed to retrieve the selec-
tion. _O_f_f_s_e_t specifies an offset position into the selec-
tion, _b_u_f_f_e_r specifies a location at which to copy informa-
tion about the selection, and _m_a_x_B_y_t_e_s specifies the amount
of space available at _b_u_f_f_e_r. _P_r_o_c should place a NULL-
terminated string at _b_u_f_f_e_r containing _m_a_x_B_y_t_e_s or fewer
characters (not including the terminating NULL), and it
should return a count of the number of non-NULL characters
stored at _b_u_f_f_e_r. If the selection no longer exists (e.g.
it once existed but the user deleted the range of characters
containing it), then _p_r_o_c should return -1.
When transferring large selections, Tk will break them up
into smaller pieces (typically a few thousand bytes each)
for more efficient transmision. It will do this by calling
_p_r_o_c one or more times, using successively higher values of
_o_f_f_s_e_t to retrieve successive portions of the selection. If
_p_r_o_c returns a count less than _m_a_x_B_y_t_e_s it means that the
entire remainder of the selection has been returned. If
_p_r_o_c's return value is _m_a_x_B_y_t_e_s it means there may be addi-
tional information in the selection, so Tk must make another
call to _p_r_o_c to retrieve the next portion.
_P_r_o_c always returns selection information in the form of a
character string. However, the ICCCM allows for information
to be transmitted from the selection owner to the selection
requestor in any of several formats, such as a string, an
array of atoms, an array of integers, etc. The _f_o_r_m_a_t argu-
ment to Tk_CreateSelHandler indicates what format should be
used to transmit the selection to its requestor (see the
middle column of Table 2 of the ICCCM for examples). If
_f_o_r_m_a_t is not STRING, then Tk will take the value returned
Tk 2
Tk_CreateSelHandler(3)Tk Library Procedures
by _p_r_o_c and divided it into fields separated by white space.
If _f_o_r_m_a_t is ATOM, then Tk will return the selection as an
array of atoms, with each field in _p_r_o_c's result treated as
the name of one atom. For any other value of _f_o_r_m_a_t, Tk
will return the selection as an array of 32-bit values where
each field of _p_r_o_c's result is treated as a number and
translated to a 32-bit value. In any event, the _f_o_r_m_a_t atom
is returned to the selection requestor along with the con-
tents of the selection.
If Tk_CreateSelHandler is called when there already exists a
handler for _t_a_r_g_e_t on _t_k_w_i_n, then the existing handler is
replaced with a new one.
Tk_DeleteSelHandler removes the handler given by _t_k_w_i_n and |
_t_a_r_g_e_t, if such a handler exists. If there is no such |
handler then it has no effect.
KEYWORDS
format, handler, selection, target
Tk 3